#ifndef _DINT_
#define _DINT_

#include <type.h>
/*This file includes the absolutely generalized driver interface
that will be provided to all the assistant hardware code in the
kernel. It is expected to introduce some system and organization
in the management of drivers and will be an improvement over
simply calling the hardware code. In addition to this the
driver interface will also maintain statistical data concerned
with the drivers that will be useful primarily for
debugging purposes. The driver interface includes a database
for registration of all the driver structures also and hence
will also include display functions exclusively for debugging
purposes */

#define MAX_CHILD 10

typedef struct {
	u32 global_id;	//Global id of device
	char name[20];	//Name
	u64 uptime;	//Uptime through scheduler
	int failures;
	int (*init)();
	int (*reset)();
	int (*deinit)();
	unsigned (*read_device)(unsigned p0,unsigned p1,unsigned p2,unsigned p3);
	unsigned (*write_device)(unsigned p0,unsigned p1,unsigned p2,unsigned p3);
	int device_irq;
	void *device;		//Type specific structure;
	char *device_desc;
	int buf_ptr;
	int up;
}kdrv;

struct init_kdrv	{
	kdrv *d;
	char sign[4];
};

#define __init(a,b) struct init_kdrv a={.d=&b,.sign="bNiN"}

#define DEVICE_IRQ_UNUSED 0xff

struct reg_drv	{
	kdrv *driver;
	struct reg_drv *next;
};

int init_dint();
int register_driver(kdrv *x);
int start_dev(kdrv *x);
void *get_driver(char *name);
int display_registered();
int device_error(kdrv *driver,const char *msg);
int bring_down();
void *get_driver(char *name);
void *get_device(char *name);
u8 *bnsys_open(char *filename);
int bnsys_query(char *filename);

int show_driver(char *name);


/*Common device reads:*/
#define READ_VER		0x0
#define READ_INSTALL	0x1
#define READ_ERROR		0x2

#define WRITE_DEF	0x100
#define READ_DEF	0x100


#endif
